package experiment12;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class No_1 extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        BorderPane pane=new BorderPane();
        HBox color_select=new HBox();
        Text text=new Text("Programming is Fun");
        text.setFont(new Font(40));
        HBox move=new HBox();

        Pane pane1=new Pane();
        pane.getChildren().add(text);
        text.setX(0);
        text.setY(100);

        pane.setTop(color_select);
        pane.setCenter(pane1);
        pane.setBottom(move);

        Button move_left=new Button("<=");
        Button move_right=new Button(">=");
        move.setAlignment(Pos.BOTTOM_CENTER);
        move.getChildren().addAll(move_left,move_right);

        RadioButton red=new RadioButton("Red");
        RadioButton yellow=new RadioButton("Yellow");
        RadioButton black=new RadioButton("Black");
        RadioButton orange=new RadioButton("Orange");
        RadioButton green=new RadioButton("Green");
        ToggleGroup group=new ToggleGroup();
        red.setToggleGroup(group);
        yellow.setToggleGroup(group);
        black.setToggleGroup(group);
        orange.setToggleGroup(group);
        green.setToggleGroup(group);
        color_select.getChildren().addAll(red,yellow,black,orange,green);


        red.setOnAction(event -> {
            text.setFill(Color.RED);
            text.setStroke(Color.RED);
        });
        yellow.setOnAction(event -> {
            text.setFill(Color.YELLOW);
            text.setStroke(Color.YELLOW);
        });
        black.setOnAction(event -> {
            text.setFill(Color.BLACK);
            text.setStroke(Color.BLACK);
        });
        orange.setOnAction(event -> {
            text.setFill(Color.ORANGE);
            text.setStroke(Color.ORANGE);
        });
        green.setOnAction(event -> {
            text.setFill(Color.GREEN);
            text.setStroke(Color.GREEN);
        });
        move_left.setOnAction(event -> {
            text.setX(text.getX()-2);
        });
        move_right.setOnAction(event -> {
            text.setX(text.getX()+2);
        });
        primaryStage.setTitle("text change color");
        primaryStage.setScene(new Scene(pane,400,200));
        primaryStage.show();
    }
}
